package com.sxpi.course.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sxpi.course.pojo.CoursePrise;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;

/**
 * @Author: 董伟豪
 * @Date: 2022/11/15 11:00
 */
public interface CoursePriseMapper extends BaseMapper<CoursePrise> {

    /**
     * 保存用户点赞信息
     * @param courseParise
     * @return
     */
    int insertCoursePrise(CoursePrise courseParise);

    /**
     * 查看某个用户的课程点赞记录
     * @param courseId
     * @param userId
     * @return
     */
    CoursePrise selectByCourseIdAndUserId(@Param("courseId")Long courseId,
                                           @Param("userId")Long userId);

    /**
     * 根据课程id查询总的点赞记录
     * @param courseId
     * @return
     */
    int countByCourseId(@Param("courseId")Long courseId);

    /**
     * 用户取消课程的点赞记录
     * @param courseId
     * @param userId
     * @return
     */
    int cancelCourseParise(@Param("courseId")Long courseId,@Param("userId")Long userId);

    /**
     * 获取课程的点赞的总数排行
     * @return
     */
    List<Map<String,Object>> getCoursePariseRank();
}
